#include <string>
#include <iostream>
#include <cmath>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include "gtec.h"
#include "recursos.h"

using namespace std;
  
c_gtec::c_gtec(string no, int c, int n, int nd, string * d,TTF_Font * f)
{
 desc = new SDL_Surface*[nd];
 ndesc = nd;
 
 SDL_Color colorfuente;
 colorfuente.r = 0; colorfuente.g = 0; colorfuente.b = 0;

 for(int i = 0;i < nd;i++)
 {
  char * a = stringachar(d[i]);
  desc[i] = TTF_RenderText_Blended(f,a,colorfuente);
  delete a;
 }
 
 char campo[100]; 
 
 char * a;
 a = stringachar(no);
 nom = TTF_RenderText_Blended(f,a,colorfuente); 
 delete a;
 //c = c * (int)pow((double)2,(double)n);
 a = intachar(c); 
 strcpy(campo,"Coste: ");
 strcat(campo,a);
 coste = TTF_RenderText_Blended(f,a,colorfuente); 
 delete a;
 a = intachar(n); 
 strcpy(campo,"Nivel: ");
 strcat(campo,a);
 nivel = TTF_RenderText_Blended(f,campo,colorfuente); 
 delete a;
}

c_gtec::~c_gtec()
{
 for(unsigned int i = 0;i < ndesc;i++)
  SDL_FreeSurface(desc[i]);
 
 delete desc;
 
 SDL_FreeSurface(nom);
 SDL_FreeSurface(coste);
 SDL_FreeSurface(nivel);
}
